Logical Router Processing by Network Controller

ABSTRACT

Some embodiments provide a method for a network controller. The method receives configuration data, for a logical router managed by the network controller, that specifies at least one logical port for the logical router. The method automatically generates connected routes for the logical router based on network address ranges specified for the logical ports of the logical router. The method receives a manually input static route for the logical router. The method generates data tuples, for distribution to several managed network elements, based on the connected and static routes for the logical router in order for the several managed network elements to implement the logical router.

BACKGROUND

In traditional physical networking, routes come in threetypes—connected, static, and dynamic. Connected routes are thosedetermined automatically based on local interface information. When aninterface has an address configured in a subnet, then the router has adirectly connected route to that subnet. Static routes are thosemanually configured at the router, and dynamic routes are learned fromother routers via routing protocols (e.g., BGP, OSPF, IGP, etc.). Asthis may result in a router being presented with multiple routes for thesame IP address, routers perform various processing techniques in orderto choose between these routes.

Virtual networks may also have routers, referred to as logical routers.Previous implementations of logical routers have only used connectedroutes, however, generated based on the IP prefix configured on the portof the logical router. Adding different types of routes to logicalrouters would pose the problem of requiring additional processingtechniques for the logical routers, which may not be easily performed bythe software forwarding elements often used to implement such logicalrouters.

BRIEF SUMMARY

Some embodiments provide a network control system that enables staticroute support for logical routers. In some embodiments, the logicalrouter is managed by a network controller, which receives the input fora static route (e.g., through an API) and incorporates the static routeinto its stored state for the logical router. In order for the logicalrouter to be implemented in a physical network managed by the networkcontroller of some embodiments, the controller generates a routing tablefor the logical router and distributes the routing table to variouselements in the network that implement the logical router. In someembodiments, the network controller distributes this routing table(including the static route information) as (i) flow entries distributedto managed forwarding elements and (ii) data tuples defining a routingtable for a virtualized container (e.g., a namespace) that operates as aL3 gateway for communicating with external networks.

In some embodiments, the network controller that manages the logicalrouter receives a definition of a static route through its API (e.g., asinput by an administrator through a cloud management application). Inaddition, the controller generates routes for the logical router basedon the configuration (also received through the API) of a logicalnetwork of which the logical router is a part. The logical network ofsome embodiments may contain logical switches that attach to the logicalrouter, and subnets are defined for these logical switches (and thus forthe logical ports of the logical router to which the logical switchesattach). Based on the subnets defined for these logical ports, thenetwork controller of some embodiments generates routes that sendnetwork addresses in the subnets to the respective interfaces. Whenstatic routes are received, the controller automatically calculates aninput routing table and, from this, generates an output routing table.The routes in the output routing table are then distributed to themanaged forwarding elements and L3 gateways in order to implement thelogical router.

The network controller of some embodiments uses a table mapping engineto perform most of its state calculations (e.g., generating flow entriesto implement logical networks, generating data tuples for logicalservices and routing tables for L3 gateways, etc.). However, in someembodiments, in order to convert an input set of routes into an outputset of routes, the table mapping engine uses a separate route processingengine. Whereas the table mapping engine of some embodiments isimplemented in a first programming language useful for performing joinoperations between sets of tables (e.g., datalog, nLog, etc.), the routeprocessing engine of some embodiments is implemented in a secondprogramming language useful for performing recursive processes and errorchecking (e.g., C, C++, etc.).

This route processing engine of some embodiments receives a set ofroutes from the table mapping engine (e.g., routes automaticallygenerated by the table mapping engine based on the subnets to which thelogical ports of the logical router connect, static routes input throughthe network controller API) and performs a recursive traversal processon the routes in order to identify a final logical destination for eachnetwork address range routed by the logical router. When multiple inputroutes provide contradictory information for a particular networkaddress or range of addresses, the route processing engine of someembodiments determines which route has a higher priority. Some inputroutes may provide a next hop address rather than output port for aroute. In these cases, the route processing engine recursively traversesthe set of input routes until reaching a route specifying either adestination output port or a drop packet action. The route processingengine returns the set of output routes, with final actions (e.g., droppacket, send to particular output port) specified for each route.

Upon receiving the output set of routes from the route processingengine, the table mapping engine of some embodiments generates theinformation to distribute to the network elements (e.g., managedforwarding elements, managed gateways) in order for the network elementsto implement the logical router. These may include flow entries sent tothe managed forwarding elements (specifying, e.g., to forward packetswith certain network addresses to certain logical ports) as well asrouting table information for the gateways (e.g., data tuples defining arouting table for an IP stack operating in a namespace). In addition toflow entries that implement the logical routing table (specifying toforward packets to a particular logical port), the table mapping engineof some embodiments also generates flow entries that map the logicalport to physical interfaces so that packets can be sent across thephysical managed network between managed forwarding elements.

The preceding Summary is intended to serve as a brief introduction tosome embodiments of the invention. It is not meant to be an introductionor overview of all inventive subject matter disclosed in this document.The Detailed Description that follows and the Drawings that are referredto in the Detailed Description will further describe the embodimentsdescribed in the Summary as well as other embodiments. Accordingly, tounderstand all the embodiments described by this document, a full reviewof the Summary, Detailed Description and the Drawings is needed.Moreover, the claimed subject matters are not to be limited by theillustrative details in the Summary, Detailed Description and theDrawing, but rather are to be defined by the appended claims, becausethe claimed subject matters can be embodied in other specific formswithout departing from the spirit of the subject matters.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features of the invention are set forth in the appendedclaims. However, for purpose of explanation, several embodiments of theinvention are set forth in the following figures.

FIG. 1 conceptually illustrates the architecture of a network controller100 of some embodiments.

FIG. 2 conceptually illustrates a logical network architecture of someembodiments that includes a logical router.

FIG. 3 illustrates a centralized logical router implementation of thelogical network of FIG. 2 in a managed network of some embodiments.

FIG. 4 illustrates a distributed logical router implementation of thelogical network of FIG. 2 in a managed network of some embodiments.

FIG. 5 conceptually illustrates a network control system of someembodiments for provisioning managed forwarding elements and L3 gatewaysin order to implement logical networks.

FIG. 6 conceptually illustrates the propagation of data through thehierarchical network control system of some embodiments.

FIG. 7 conceptually illustrates the receipt of a logical networkconfiguration by a controller.

FIG. 8 conceptually illustrates the receipt by a controller ofconfiguration data for a static route for the logical router.

FIG. 9 conceptually illustrates computation performed by a networkcontroller based on a static route configured for a logical router.

FIG. 10 conceptually illustrates a process of some embodiments forreceiving a logical static route, determining whether the route isvalid, and storing the route as configuration state data if valid.

FIG. 11 conceptually illustrates a network controller of someembodiments, and the data flow through the controller as the controllerperforms route processing operations.

FIGS. 12A-B conceptually illustrate a process performed by the routeprocessing engine of some embodiments to generate a set of output routeinformation for a set of input routes of a logical router.

FIGS. 13-16 conceptually illustrate various example input and outputsets of route information.

FIG. 17 conceptually illustrates an electronic system with which someembodiments of the invention are implemented.

DETAILED DESCRIPTION

In the following detailed description of the invention, numerousdetails, examples, and embodiments of the invention are set forth anddescribed. However, it will be clear and apparent to one skilled in theart that the invention is not limited to the embodiments set forth andthat the invention may be practiced without some of the specific detailsand examples discussed.

Some embodiments provide a network control system that enables staticroute support for logical routers. In some embodiments, the logicalrouter is managed by a network controller, which receives the input fora static route (e.g., through an API) and incorporates the static routeinto its stored state for the logical router. In order for the logicalrouter to be implemented in a physical network managed by the networkcontroller of some embodiments, the controller generates a routing tablefor the logical router and distributes the routing table to variouselements in the network that implement the logical router. In someembodiments, the network controller distributes this routing table(including the static route information) as (i) flow entries distributedto managed forwarding elements and (ii) data tuples defining a routingtable for a virtualized container (e.g., a namespace) that operates as aL3 gateway for communicating with external networks.

The network controller of some embodiments uses a table mapping engineto perform most of its state calculations (e.g., generating flow entriesto implement logical networks, generating data tuples for logicalservices and routing tables for L3 gateways, etc.). However, in someembodiments, in order to generate the routing table for distributionbased on a set of input routes, the table mapping engine uses a separateroute processing engine. Whereas the table mapping engine of someembodiments is implemented in a first programming language useful forperforming join operations between sets of tables (e.g., datalog, nLog,etc.), the route processing engine of some embodiments is implemented ina second programming language useful for performing recursive processesand error checking (e.g., C, C++, etc.).

FIG. 1 conceptually illustrates the architecture of such a networkcontroller 100 of some embodiments. As shown, the network controller 100includes an input interface (e.g., an API) 105, a table mapping engine110, a route processing engine 115, and a state distribution interface120. In addition, the network controller 100 includes a state storage125. The state storage 125, in some embodiments, stores informationabout one or more logical networks implemented within a physical networkmanaged by the controller 100.

In some embodiments, the network controller 100 is one of severalcontrollers that manages numerous managed forwarding elements thatimplement multiple logical networks across numerous host machines. Forexample, a logical network might include several logical switches thatattach to a logical router, with numerous virtual machines (VMs)attached to the logical switches. The VMs reside on numerous hostmachines, possibly alongside VMs of other logical networks. A managedforwarding element (MFE) operates on each host machine (e.g., as asoftware forwarding element residing in the virtualization software ofthe host machine) in order to process packets sent to and received fromthe VMs on that host machine. In some embodiments, the MFE on aparticular host machine stores information in order to implement thelogical forwarding elements for the various different logical networksthat have VMs residing on the host machine.

The network controller 100 may manage a particular one (or several) ofthese logical networks, and therefore stores information in the statestorage 125 about the logical forwarding elements. In some embodiments,the network controller 100 receives configuration information definingthe logical network that it manages, and computes additional informationfor distribution to the MFEs in order to implement the logical network.The state storage 125 stores both configuration state and computed stateinformation for all of the logical forwarding elements of the logicalnetworks managed by the controller 100. In addition, in someembodiments, other controllers share configuration state informationwith the network controller 100 for other logical networks that are notmanaged by the controller 100. However, in some such embodiments, thecontrollers do not share computed state information, and each controlleronly computes state for the logical networks that it manages.

The input interface 105 is an application programming interface (API) insome embodiments, through which the network controller 100 receivesconfiguration information. The configuration information may be input byan administrator logging into the network controller directly, orthrough a management application that translates administrator-enteredinformation into API commands to send to the controller. In addition,the network controller 100 may receive as configuration information adefinition of a static route through the input interface 105. Uponreceiving this information, the input interface stores the configurationdata into the state storage 125. In some embodiments, each logicalforwarding element (e.g., the logical router) is stored as an object,and the routes are stored as objects which are owned by the logicalrouter object. To define a configured route in the state storage 125,some embodiments store the type of route (e.g., connected, static), thenetwork address or range of addresses governed by the route, adestination (e.g., a next hop address, a logical port, a drop action)for packets having a network address in the range governed by the route,and a priority for the route.

The table mapping engine 110 performs state calculations for logicalnetworks managed by the controller 100, in some embodiments. These statecalculations may include generating flow entries to implement thelogical networks, generating data tuples for logical services androuting tables for L3 gateways, etc. In some embodiments, the tablemapping engine is implemented in a table mapping language that performsjoin operations between sets of tables, such as nLog or datalog. Whenthe table mapping engine 110 of some embodiments receives a set ofroutes for a logical router that includes one or more static routes(i.e., that includes routes other than those defined automatically basedon the logical ports of the logical router), the table mapping engineutilizes the route processing engine 115 to translate the input set ofroutes into an output set of routes.

The route processing engine 115 of some embodiments receives a set ofroutes from the table mapping engine (e.g., routes automaticallygenerated by the table mapping engine or network controller API based onthe subnets to which the logical ports of the logical router connect,static routes input through the network controller API) and performs arecursive traversal process on the routes in order to identify a finallogical destination for each network address range routed by the logicalrouter. When multiple input routes provide contradictory information fora particular network address or range of addresses, the route processingengine 115 of some embodiments determines which route has a higherpriority. Some input routes may provide a next hop address rather thanoutput port for a route. In these cases, the route processing enginerecursively traverses the set of input routes until reaching a routespecifying either a destination output port or a drop packet action. Theroute processing engine 115 returns the set of output routes, with finalactions (e.g., drop packet, send to particular output port) specifiedfor each route. In some embodiments, the route processing engine 115 isimplemented in a language different from the table mapping engine (i.e.,not a table mapping language). Specifically, some embodiments implementthe route processing engine in a language that is optimal for errorchecking and recursive traversal processes (e.g., C, C++ etc.).

Upon receiving the output set of routes from the route processingengine, the table mapping engine 110 of some embodiments generates theinformation to distribute to the network elements (e.g., managedforwarding elements and managed gateways residing on the host machines130) in order for the network elements to implement the logical router.This data may include flow entries sent to the managed forwardingelements (specifying, e.g., to forward packets with certain networkaddresses to certain logical ports) as well as routing table informationfor the gateways (e.g., data tuples defining a routing table for an IPstack operating in a namespace). In addition to flow entries thatimplement the logical routing table (specifying to forward packets to aparticular logical port), the table mapping engine 110 of someembodiments also generates flow entries that map the logical port tophysical interfaces so that packets can be sent across the physicalmanaged network between managed forwarding elements.

The controller 100 distributes the data for the logical router (andother data for, e.g., other logical forwarding elements, such as thelogical switches of the logical network) generated by the table mappingengine 110 to the host machines 130 via the state distribution interface120. In some embodiments, the controller 100 distributes the datathrough a hierarchy of other network controllers. For instance, in someembodiments, each logical network (or each logical forwarding element)is managed by a particular controller (which may also manage otherlogical networks), and each host machine is managed by a particularcontroller (which may also manage other host machines). The controller100 computes the state (e.g., flow entries) for logical networks that itmanages, and distributes this data to the various controllers thatmanage the host machines implementing those logical networks. In otherembodiments, the state distribution interface 120 interfaces directlywith the host machines 130 to distribute the data.

An example operation of the network controller 100 will now bedescribed. In some embodiments, a user inputs a configuration for alogical network, which may include several logical switches connected toa logical router. Each logical switch connects to a logical port of thelogical router, and each logical port is assigned a subnet (i.e., arange of network addresses). In addition, the user inputs at least onestatic route. The network controller 100 receives the configuration data(including the configuration of the static route) through the inputinterface 105.

Based on the received configuration data, the input interface 105 storesconfiguration state in the state storage 125. With respect to thelogical router, the input interface stores (1) a connected route foreach logical port, for routing packets with network addresses in therange specified for the logical port to that logical port, and (2)static routes as defined by the configuration data. In some embodiments,the input interface 105 also automatically defines a low-prioritydefault route for handling packets sent to network addresses for whichroutes are not otherwise defined (e.g., to a logical gateway port). Inother embodiments, such a default route is only defined if input by auser.

Upon detecting the change in the configuration state stored in the statestorage 125, the table mapping engine 110 begins generating new datatuples for distribution to the host machines in order to implement thelogical network. However, because static routes are defined, the tablemapping engine 110 offloads the route traversal to the route processingengine 115. Specifically, the table mapping engine 110 sends to theroute processing engine 120 an input set of routes (i.e., those definedby the configuration state)

The route processing engine 115 generates an output set of routes fromthe received set of input routes. Specifically, the route processingengine identifies routes that are not in use (e.g., lower priorityroutes that are superseded by higher priority routes for the same set ofnetwork addresses), and recursively traverses the set of routes toidentify a final action for each set of network addresses (e.g., a droppacket action, a final output port to which to send packets). The routeprocessing engine 115 returns the final route information to the tablemapping engine 110.

The table mapping engine 110 uses the final route information togenerate flow entries and/or data tuples defining the implementation ofthe logical router for the host machines 130. The table mapping engine110 provides these generated data tuples to the state distributioninterface 120 for distribution to the host machines 130 (e.g., directlyto the host machines, through a hierarchical network control system,etc.).

The above description introduces the network controller of someembodiments for managing logical routers with static routing. Severalmore detailed embodiments are described below. First, Section Iintroduces the implementation and configuration of logical networks viaa network control system of some embodiments. Section II then describesthe configuration of static routes for a logical router, and Section IIIdescribes the operation of the route processing engine in a controlleraccording to some embodiments. Finally, Section IV describes anelectronic system with which some embodiments of the invention areimplemented.

I. Provisioning of Logical Networks

In some embodiments, the network controllers (e.g., the controllerdescribed above by reference to FIG. 1) are part of a network controlsystem used to manage numerous logical networks implemented in aphysical managed network (e.g., a private datacenter such as anenterprise site, a public datacenter, etc.). In such a managed network,different tenants configure different logical networks, which thenetwork control system implements in a virtualized fashion over the samephysical network, while maintaining isolation between the logicalnetworks.

FIG. 2 conceptually illustrates an example logical network architecture200. The logical network 200 includes two logical switches 205 and 210and a logical router 215. Each of the logical switches 205 and 210connects several virtual machines (in this case, two virtual machines(VMs) are connected by each logical switch, though many networks willhave far more VMs attached to each logical switch), and the logicalrouter 215 connects the two logical switches (i.e., logical layer 2domains) together. In addition, the logical router 215 connects thelogical network to an external network 220. While in this example, thelogical router 215 has a single port connecting to the external network,in some embodiments the logical router may have several uplink ports toconnect to the external networks.

In some embodiments, the logical network is an abstract conception of anetwork generated by an administrator, and the logical network isimplemented in a virtualized, distributed manner in a managed physicalinfrastructure (e.g., in a multi-tenant datacenter). That is, thevirtual machines that connect to the logical switches may reside onvarious different host machines within the infrastructure, and physicalmanaged forwarding elements (e.g., software virtual switches) operatingon these host machines implement some or all of the logical forwardingelements (logical switches, logical routers, etc.).

A logical router, as in this example, connects a set of logical switchesto which virtual machines logically attach. Each logical switch (or eachlogical port of the logical router to which a logical switch attaches)represents a particular set of IP addresses (i.e., a subnet), and isimplemented in the managed network across a set of managed forwardingelements (MFEs) to which the virtual machines physically connect (e.g.,through virtual interfaces). In some embodiments, the logical routersare implemented in a centralized manner (e.g., in one or more redundantgateways), rather than distributed across the MFEs with the logicalswitches. In other embodiments, the logical routers are implemented in adistributed fashion as well by the MFEs that connect to the virtualmachines. However, when the logical router also connects to the externalnetwork via one or more ports, these connections to the external networkare implemented through the use of one or more gateways. The gateways,in some embodiments, are responsible for both sending data traffic fromthe managed network to the external unmanaged physical network andprocessing traffic sent from the external network into the managednetwork.

FIGS. 3 and 4 conceptually illustrate two different implementations forthe logical network 200, depending on whether the logical router isimplemented in a centralized or distributed fashion. FIG. 3 illustratesa centralized logical router implementation in a managed network 300 ofsome embodiments. In this case, a gateway host machine implements theentire routing table of the logical router 215. The gateway host has aconnection outside the managed network to at least one physical router375 that is part of the external network 220. While shown as beingimplemented in a single gateway host, some embodiments in fact implementthe logical router in a high-availability manner, with one activegateway and at least one standby gateway. The high-availability gatewaysfor logical routers are described greater detail in U.S. applicationSer. No. 14/166,446, filed Jan. 28, 2014, and entitled “HighAvailability L3 Gateways for Logical Networks”, which is incorporatedherein by reference.

As shown, the physical infrastructure of the managed network 300includes three host machines 305-315 for hosting virtual machines, and agateway host machine 325. The VMs of the logical network 200 reside onthe hosts 305-315, implemented on top of virtualization software (e.g.,a hypervisor, virtual machine monitor, etc.) that operates in the host.Additional virtual machines that connect to other logical networks mayalso reside on some or all of these hosts 305-315 in the physicalinfrastructure of the managed network, as well as on other hosts (notshown in this figure).

In addition to the virtual machines, each of the hosts 305-315 operatesa managed forwarding element (MFE) 335-345. In some embodiments, thisMFE is a software virtual switch that operates within the virtualizationsoftware of the host (e.g., Open vSwitch, or another software forwardingelement). In the implementation illustrated in FIG. 3, the managedforwarding elements in the hosts 305-315 implement the logical switches205 and 210. As shown, because only VM 1 resides on the first host 305,only the logical switch 205 to which this VM connects is implemented bythe MFE 335 (though other logical switches for other logical networksmay also be implemented by the MFE). Similarly, the MFE 345 onlyimplements the second logical switch 210, while the MFE 340 implementsboth logical switches 205 and 210. In other embodiments, each of theseMFEs 335-345 implements both logical switches.

In this centralized implementation of the logical network 200, none ofthe MFEs 335-345 that run in the VM hosts 305-315 implement the logicalrouter 215. Instead, the entire routing table of the logical routerresides in the gateway host 325. As shown, a namespace 350 (or othervirtualized container) operates on the gateway host in order toimplement the logical router 215. When one of the MFEs 335-345determines that a packet sent by one of the VMs of the logical network200 requires logical router processing, the MFE sends the packet to thelogical router implemented by the namespace 350. Some embodimentsutilize tunnels between the MFEs 335-345 and the MFE 355 located in thegateway host 325. In some embodiments, the MFEs 335-345 are provisionedsuch that when a packet is logically forwarded to a logical router, theMFE encapsulates the packet in a tunnel to the MFE 355 operating on thegateway host 325. As mentioned, some embodiments implement the logicalrouter 215 in several gateway hosts, with one host active. In this case,the MFEs 305-315 send packets to the active host unless that tunnel isdown, in which case the MFEs send the packets to one of the standbyhosts.

In other embodiments, the managed forwarding elements in the VM hostmachines implement the logical router in a distributed manner, with thelogical routers implemented in the gateways only functioning to processpackets sent from machines in the managed network to destinationsoutside the managed network and to process packets sent from sourcesoutside the managed network to machines in the managed network. FIG. 4conceptually illustrates such a distributed implementation in a managednetwork 400. In this case, a namespace operating in a gateway hostmachine only implements the routing table for packets entering oregressing the managed network, rather than the entire routing table forthe logical router 215.

As in the previous figure, the portion of the physical infrastructure ofthe managed network 400 that implements the logical network 200 includesthree host machines 405-415 for hosting virtual machines and a gatewayhost machine 435 that hosts a L3 gateway in a namespace 440. In thiscase, the managed forwarding elements 420-430 that operate on the hosts405-415 (e.g., within the virtualization software of these hosts) notonly implement the logical switches 205 and 210, but also the logicalrouter 215. This enables first-hop logical processing in someembodiments, in which all or most of the logical processing for a packetis performed at the first MFE that receives the packet. Thus, a packetsent from VM 1 to VM 4 would be processed, at the MFE 420, throughlogical switch 205 to logical router 215 and then to logical switch 210.The MFE 420 would identify the logical egress port of logical switch 210for the packet as the port to which VM 4 attaches, and map this egressport to a tunnel to the MFE 425 at host 410.

However, for traffic sent to an external destination (i.e., notconnected to either logical switch), the MFE identifies a logical egressport of the logical router as the port that connects to the externalnetwork. The MFE then sends this traffic to the gateway host 435 onwhich the L3 gateway is implemented (i.e., the north-south routingportion of the routing table, for packet sent into and out of themanaged network). As in the centralized embodiments, in some embodimentsthe L3 gateway is implemented with one active gateway and one or morestandby gateways.

As described above, these MFEs and gateways are provisioned, in someembodiments, by a network control system. One or more networkcontrollers in the network control system receive the networkconfiguration input by a user/administrator and convert this informationinto flow entries and/or data tuples that can be used by the MFEs andgateway host machines, and distributes the data tuples to the hostmachines.

FIG. 5 conceptually illustrates such a network control system 500 ofsome embodiments for provisioning managed forwarding elements and L3gateways (whether these gateways implement an entire logical routerrouting table or only the network ingress/egress portion of the routingtable) in order to implement logical networks. As shown, the networkcontrol system 500 includes an input translation controller 505, alogical controller 510, physical controllers 515 and 520, host machines525-540, and a gateway host machine 545. As shown, the hosts 525-540, aswell as the gateway host 545, include managed forwarding elements, whichmay implement logical forwarding elements as shown in the above figures.The gateway host 545 also includes a namespace, which implements atleast a portion of a routing table for a logical router of the managednetwork. One of ordinary skill in the art will recognize that many otherdifferent combinations of the various controllers and hosts are possiblefor the network control system 500.

In some embodiments, each of the controllers in a network control systemis a computer (e.g., with an x86-based processor) with the capability tofunction as an input translation controller, logical controller, and/orphysical controller. Alternatively, in some embodiments a givencontroller may only have the functionality to operate as a particularone of the types of controller (e.g., as a physical controller). Inaddition, different combinations of controllers may run in the samephysical machine. For instance, the input translation controller 505 andthe logical controller 510 may run in the same computing device, withwhich a data center management application interacts (or with which anadministrator interacts directly).

The input translation controller 505 of some embodiments includes aninput translation application that translates network configurationinformation received from a user. While shown as receiving theinformation directly from the user in FIG. 5, in some embodiments a userinteracts with a data center management application, which in turnpasses the network configuration information to the input translationcontroller.

For example, a user may specify a network topology such as that shown inFIG. 2. For each of the logical switches, the user specifies themachines that connect to the logical switch (i.e., to which logicalports of the logical switch the VMs are assigned). The user may alsospecify which logical switches attach to any logical routers, a logicalport of the logical router for connection to external networks, and anyconfiguration details for the logical router. The input translationcontroller 505 translates the received network topology into logicalcontrol plane data that describes the network topology as a set of datatuples in some embodiments. For example, an entry might state that aparticular MAC address A is located at a first logical port X of aparticular logical switch, that a logical router Q is located at asecond logical port Y of the particular logical switch, or that alogical port G of the logical router Q is a gateway port to an externalnetwork.

In some embodiments, each logical network is governed by a particularlogical controller (e.g., logical controller 510). The logicalcontroller 510 of some embodiments translates the logical control planedata that defines the logical network and the logical forwardingelements (e.g., logical routers, logical switches) that make up thelogical network into logical forwarding plane data, and the logicalforwarding plane data into physical control plane data. The logicalforwarding plane data, in some embodiments, consists of flow entriesdescribed at a logical level. For the MAC address A at logical port X,logical forwarding plane data might include a flow entry specifying thatif the destination of a packet matches MAC A, to forward the packet toport X. The port of the logical router Q will also have a MAC address,and similar flow entries are created for forwarding packets with thisMAC address to port Y of the logical switch. Similarly, for a logicalrouter with a port K to which a logical switch having a range of IPaddresses C1-C24, the logical forwarding plane data might include a flowentry specifying that if the destination of a packet matches IP C1-C24,to forward the packet to port K.

In some embodiments, the logical controller translates the logicalforwarding plane data into universal physical control plane data. Theuniversal physical control plane data enables the network control systemof some embodiments to scale even when the network includes a largenumber of managed forwarding elements (e.g., hundreds, thousands) toimplement a logical forwarding element, and when the network implementsa large number of logical networks. The universal physical control planeabstracts common characteristics of different MFEs in order to expressphysical control plane data without considering differences in the MFEsand/or location specifics of the MFEs.

As stated, the logical controller 510 of some embodiments translateslogical control plane data into logical forwarding plane data (e.g.,logical flow entries that include a match over logical networkparameters, such as logical addresses, logical ingress ports, etc.),then translates the logical forwarding plane data into universalphysical control plane data. In some embodiments, the logical controllerapplication stack includes a control application for performing thefirst translation and a virtualization application for performing thesecond translation. Both of these applications, in some embodiments, usea rules engine for mapping a first set of tables into a second set oftables. That is, the different data planes are represented as tables(e.g., nLog tables), and the controller applications use a table mappingengine (e.g., an nLog engine) to translate between the planes (e.g., byapplying join operations on the tables). The input and output tables, insome embodiments, store sets of data tuples that define the differentplanes of data.

In some embodiments, the logical router processing entails recursiveroute traversal processes and various types of error checking that arenot optimally performed by the table mapping engine. Specifically, theconfiguration data for a logical router includes a set of input routes(analogous to the routing information base of a physical router) thatmust be narrowed to a set of output routes used to implement the routingtable of the logical router (analogous to the forwarding informationbase of a physical router). In some embodiments, this set of outputroutes is part of the logical control plane data. In order to generatethis logical control plane data for the logical router, the tablemapping engine of some embodiments offloads the route processing to aseparate module in the logical controller, implemented in a languagebetter suited to such recursive and error checking/generation actions.The route processing engine returns a set of output routes that thetable mapping engine incorporates into its generation of logicalforwarding plane entries.

Each of the physical controllers 515 and 520 is a master of one or moremanaged forwarding elements (e.g., located within host machines). Inthis example, each of the two physical controllers is a master of twomanaged forwarding elements located at the VM host machines 525-540.Furthermore, the physical controller 515 is a master of two gatewayhosts 545 and 550, which host MFEs as well as the active and standbylogical routers for a particular logical network. In some embodiments,the active and standby hosts for a logical router are managed by thesame physical controller (as in this figure), while in other embodimentsseparate physical controllers manage the different gateway hosts of alogical network.

In some embodiments, a physical controller receives the universalphysical control plane data for a logical network and translates thisdata into customized physical control plane data for the particular MFEsthat the physical controller manages and which require data for theparticular logical network. In other embodiments, the physicalcontroller passes the appropriate universal physical control plane datato the MFEs, which have the ability (e.g., in the form of a chassiscontroller running on the host machine) to perform this conversionthemselves.

The universal physical control plane to customized physical controlplane translation involves a customization of various data in the flowentries. For the first example noted above, the universal physicalcontrol plane would involve several flow entries (i.e., several datatuples). The first entry states that if a packet matches the particularlogical data path set (e.g., based on the packet being received at aparticular physical ingress port), and the destination address matchesMAC A, then forward the packet to logical port X. This entry will be thesame in the universal and customized physical control planes, in someembodiments. Additional entries are generated to match a physicalingress port (e.g., a virtual interface of the host machine) to thelogical ingress port X (for packets received from the VM having MAC A),as well as to match a destination logical port X to the physical egressport of the physical MFE (e.g., again the virtual interface of the hostmachine). However, these physical ingress and egress ports are specificto the host machine on which the MFE operates. As such, the universalphysical control plane entries include abstract physical ports while thecustomized physical control plane entries include the actual physicalinterfaces (which, in many cases are virtual interfaces) of the specificMFEs.

In some embodiments, as shown, the logical router hosts also operatemanaged forwarding elements (e.g., using the same packetprocessing/virtual switching software as the VM hosts 525). These MFEsalso receive physical control plane data from the physical controllerthat enables the MFEs to implement the logical forwarding elements. Inaddition, some embodiments distribute the routing table data to thenamespaces operating in the gateway hosts through the hierarchicalnetwork control system. The logical controller 510 that manages thelogical network selects the gateway host for the logical router in someembodiments (e.g., using a load balancing algorithm that spreads thelogical routers for various logical networks across a set of hosts).

The logical controller 510 identifies the physical controller 515 thatmanages the selected gateway host, and distributes the routing table (aswell as any other information used for layer 3 processing, such asfirewall information, NAT, etc.) to the identified physical controller.In some embodiments, the routing table is distributed as a set of datatuples. The physical controller 515 then distribute these data tuples tothe gateway host 545. The gateway hosts convert these data tuples into arouting table for use by a container (e.g., a VM, a namespace) thatoperates on the gateway host as a logical router or L3 gateway.

The above describes the hierarchical network control system of someembodiments, although the network control system of other embodimentsincludes only a single controller (or a controller cluster with oneactive and one or more standby controllers). FIG. 6 conceptuallyillustrates the propagation of data through the hierarchical networkcontrol system of some embodiments. The left side of this figure showsthe data flow to the managed forwarding elements to implement thelogical forwarding elements (either the logical switches, or the logicalswitches and logical routers) of the logical network, while the rightside of the figure shows the propagation of routing table data to thegateway hosts in order to provision the logical routers (either theentire logical router or only the gateway logical router functionality).

On the left side, the input translation controller 505 receives anetwork configuration through an API, which is converted into logicalcontrol plane data. This network configuration data includes a logicaltopology such as that shown in FIG. 2. In some embodiments, the networkconfiguration may also include the specification of one or more staticroutes for a logical router. The network configuration specifiesattachments of logical switches to logical routers in some embodiments,with MAC addresses assigned to each logical router port that connects toa logical switch, and each logical switch having an associated IPsubnet.

As shown, the logical control plane data is converted by the logicalcontroller 510 (specifically, by a control application of the logicalcontroller) to logical forwarding plane data, and then subsequently (bya virtualization application of the logical controller) to universalphysical control plane data. In some embodiments, these conversionsgenerate a flow entry at the logical forwarding plane (or a data tuplethat defines a flow entry), then add a match over the logical data pathset (e.g., the logical switch or router) at the universal physicalcontrol plane. The universal physical control plane also includesadditional flow entries (or data tuples) for mapping generic physicalingress ports (i.e., a generic abstraction of a port not specific to anyparticular MFE) to logical ingress ports as well as for mapping logicalegress ports to generic physical egress ports. For instance, forforwarding a packet to a logical router, the flow entries at theuniversal physical control plane for a logical switch would include aforwarding decision to send a packet to the logical port to which thelogical router connects when the destination MAC address matches that ofthe logical router port.

In addition, for the centralized logical router, the universal physicalcontrol plane entries would include a mapping of the logical port to ageneric physical port of a host machine that connects to the gatewayhost on which the logical router resides, and generic tunneling entriesfor encapsulating the packet in a tunnel to the gateway host. On theother hand, for the distributed logical router, the universal physicalcontrol plane entries would not send all packets destined for thelogical router to the gateway, but instead include the logical routerprocessing. Similar to the examples in the previous paragraph for thelogical switch, the logical router flow entries identify a logicalegress port based on a match over (i) the logical router pipeline (i.e.,that the packet has been forwarded to the logical router) and (ii) theIP address. The mapping of IP address to logical port, in someembodiments, is based on the routing table generated by the routeprocessing engine at the logical controller. For packets forwarded to alogical router port that faces the external network, the universalphysical control plane additionally includes entries for mapping thelogical egress port to a destination gateway and encapsulating thepacket in a tunnel to the gateway.

The physical controller 515 (one of the several physical controllers inthe hierarchical network control system 500), as shown, translates theuniversal physical control plane data into customized physical controlplane data for the particular MFEs that it manages at hosts 525, 530,and 545. This conversion involves substituting specific data (e.g.,specific physical ports) for the generic abstractions in the universalphysical control plane data. For instance, in the example of the aboveparagraph, the port integration entries are configured to specify thephysical layer port appropriate for the particular logical router or L3gateway connection (e.g., an actual physical port and tunnelencapsulation information for the particular host machine on which theMFE operates).

The MFE at host 525 (one of several MFEs managed by the physicalcontroller 515) performs a translation of the customized physicalcontrol plane data into physical forwarding plane data, in someembodiments. The physical forwarding plane data, in some embodiments,are the flow entries stored within a MFE (e.g., within a softwarevirtual switch such as Open vSwitch) against which the MFE actuallymatches received packets. In addition, the MFE at the gateway host 545performs such a translation in order to forward packets between thenamespace and the other network entities (e.g., VMs).

The right side of FIG. 6 illustrates data propagated to the gatewayhosts (e.g., host 545) to implement a logical router (either acentralized logical router or a L3 gateway for a distributed logicalrouter), rather than to the MFEs. As shown, the logical controller 510receives an input set of routes, generates an output set of routes, andthen translates the output set of routes into routing data tuples fromthese routes.

In some embodiments, the input set of routes is generated by either thelogical controller or the input translation controller from the networkconfiguration input by the user (e.g., the administrator). When a userdesigns the logical network (such as network 200), each logical switchhas an associated IP subnet. From this, the logical controllerautomatically generates routes to each of these logical router portsthat attach to the logical switches (e.g., if IP=10.0.0.0/24, send toPort J). In addition, when the logical router includes a gateway port toexternal networks the logical controller of some embodiments generates alow priority default route to send packets that do not match any otherroutes to the external network. The logical controller may have data insome embodiments that identifies a physical router in the externalnetwork, so that the default route sends packets to the identifiedrouter. Furthermore, users may input static routes as part of thelogical network configuration. In some embodiments, the static routesspecify either a logical router port or a next hop network address towhich to send packets with network addresses that fall in a given range(e.g., 12.0.0.0/28).

Before calculating the flow entries or the routing data tuples for thelogical router, the logical controller of some embodiments generates anoutput set of routes based on the input set of routes. In someembodiments, a route processor in the logical controller recursivelytraverses the set of input routes to identify final output actions foreach set of network addresses. For instance, if the input set includesmultiple routes for the same network address (or set of networkaddresses), the route processor identifies those with the highestpriority as in use, and removes (for the purpose of creating a routingtable for implementation in the network) the lower priority routes. Inaddition, if a route specifies to send packets to an output port that isnot in use, then the route processor removes that route. For staticroutes that specify a next hop network address rather than an outputport, the route processor traverses the set of routes (i.e., identifyingthe route for the specified next hop network address) until a route witheither an output port or a drop action (specifying for the router todrop packets sent to the network address) is reached, then outputs thefinal action for the network address to the set of output routes.

In the centralized logical router implementation of some embodiments,all of the routes in the output set are converted into routing datatuples at the logical controller. This may be performed by the tablemapping engine in some embodiments. In the distributed implementation,much of the output set of routes is specified as part of the logicalcontrol plane data and converted into physical control plane data (asshown on the left side of FIG. 6). In this case, the routing data tuplesfor distribution to the L3 gateways will still include the routes to theexternal physical router(s), as well as routes for processing incomingpackets received via the connection with these external routers.

In addition to the routes themselves, the logical controller 510 alsogenerates a set of data tuples that defines the logical routers. Forinstance, when a logical router is created, the logical controller ofsome embodiments selects at least one gateway host, then creates a newdata tuple (i.e., a record) that specifies the new namespace (or othercontainer) on the host for the logical router. In addition, someembodiments specify in the data tuple that routing is enabled for thenamespace (as opposed to, or in addition to, other services such asDHCP).

Once the logical controller 510 creates the data tuples and identifiesthe gateway host (or hosts) that will receive the data tuples, thelogical controller then identifies the physical controller that managesthe gateway host. As mentioned, like the VM hosts 525-540, each of thegateway hosts has an assigned master physical controller. In the exampleof FIG. 5, the gateway host is managed by the physical controller 515,so the other physical controller 520 does not receive the logical routerdata tuples. In order to supply the logical router configuration data tothe gateway hosts, the logical controller 510 of some embodiments pushesthe data to the physical controller 515. In other embodiments, thephysical controllers request the configuration data (e.g., in responseto a signal that the configuration data is available) from the logicalcontroller.

The physical controller 515 passes the data to the gateway host 545,much as it passes the physical control plane data. In some embodiments,the routing data tuples are sent to a database running on the host thatis part of the software associated with the MFE, and used to configurecertain aspects of the MFE (e.g., its port information and othernon-flow entry configuration data). Some embodiments use a firstprotocol (e.g., OpenFlow) to pass the flow entries for the MFE to thehosts, while using a second protocol (e.g., OVSDB) to pass theconfiguration and routing table data to the hosts. The namespace orother container implementing the logical router retrieves theappropriate information from the database on its host, or has theappropriate information passed to it. In some embodiments, a process onthe gateway host 545 translates the data tuples stored in the databaseinto a routing table and other network stack data (e.g., a standardLinux network stack, including a routing table) for the namespace.

The above description describes the conversion, by the network controlsystem, of the network configuration into a set of physical forwardingplane flow entries that the physical controller passes to the host(e.g., via a protocol such as OpenFlow). In other embodiments, however,the data for defining flow entries is passed in other forms, such asmore abstract data tuples, and the MFEs or processes running on thehosts with the MFEs convert these data tuples into flow entries for usein processing data traffic.

II. Configuration of Static Routes

As indicated above, the network control system (e.g., the networkcontrollers) of some embodiments enable administrators to configurestatic routes for logical routers in logical networks maintained by theadministrators. These static routes are incorporated into the datastructures that store state for the logical router, along withautomatically-generated routes for the logical router. As such, thenetwork control system of some embodiments generates, from the staticroutes (and other logical router data), flow entries and data tuplesused to implement the logical router by the network elements managed bythe network control system.

FIGS. 7-9 conceptually illustrate the input of a logical networkconfiguration and static route for a logical network at a networkcontroller 700. The controller 700, as shown, includes an API 705 forreceiving configuration data, a state storage 710, and a statecomputation module 715.

The API 705 of some embodiments provides an interface through which thecontroller receives configuration state data for one or more logicalnetworks. In some embodiments, the API 705 represents a set of methodsthat may be used to create, modify, delete, query, etc. logical networkdata in the state storage 710. In some embodiments, a networkadministrator may access the controller through a direct connection(e.g., by manually inputting the API calls) or through a cloudmanagement application. In the case of a cloud management application,in some embodiments the administrator configures a logical networkthrough a graphical interface (or other intuitive interface) of theapplication, which translates the data received from the user into theappropriate API calls to the controller 700.

Some such API methods for the API 705 include methods to create alogical router, create logical router ports, create a logical switch,attach a logical switch to a logical router, attach a logical port to anexternal network, create a static route, modify a static route, remove astatic route, query a logical router for its routes, etc. These variousmethods, in some embodiments, enable the administrator to access ormodify configuration state data stored in the state storage 710.

In some embodiments, the state storage 710 stores a set of objects thatdefine logical networks managed by the controller 700. Based on commandsreceived by the API 705, the controller 700 creates objects in the statestorage 710. The state storage of some embodiments is a networkinformation base (NIB) described in detail in U.S. Patent PublicationNo. 2013/0058356, which is incorporated herein by reference, althoughother embodiments use different storages for storing state informationat the network controllers. In addition to storing the configurationstate received through the API 705, the state storage of someembodiments also stores computed state calculated by the statecomputation module 715.

Furthermore, the network controller 700 may receive state informationfrom (i) other network controllers and (ii) network elements (e.g.,MFEs) through interfaces with these entities (not shown). In someembodiments, other logical controllers receive configuration state forother logical networks, and share the configuration state informationwith the controller 700 (e.g., through an RPC channel). In some suchembodiments, the network controllers only share configuration state, anddo not share computed state. This enables an administrator to inputconfiguration data for a particular logical network into any of thenetwork controllers, as the configuration data will be shared with thenetwork controller that manages the particular logical network, and onlythat network controller will compute state for the logical network basedon the input configuration state. The managed forwarding elements andnamespaces hosting L3 gateways may also provide state information (e.g.,regarding links that are down, the amount of traffic processed forparticular logical networks, etc.) to their managing physical controller(e.g., through one of the channels used to provision the MFE ornamespace). When a physical controller receives this information, insome embodiments the controller identifies the appropriate logicalcontroller to which to provide the data, which is then stored in thestate storage of the controller (e.g., storage 710).

The state computation module (or set of modules) 715 of some embodimentsallows the controller to compute additional state information based on(i) the configuration state received through the API, (ii) previouslycomputed state (e.g., in a series of computations), and (iii) statepropagated upwards to the network controller from the physical managedforwarding elements. In some embodiments, the state computation module715 is a table mapping engine (e.g., the table mapping engine describedabove by reference to FIG. 1). The state computation module may alsoinclude a route processing engine for recursively traversingconfiguration state routes to generate computed state routes. The tablemapping engine of some embodiments is implemented in a firsttable-mapping programming language (e.g., nLog) that is optimal forperforming join operations between tables, while the route processingengine of some embodiments is implemented in a second programminglanguage (e.g., C++) that is optimal for error checking and recursiveoperations. In some such embodiments, the table mapping engine receivesthe configuration state data from the state storage 710, extracts theinput set of routes from the configuration state, and passes those inputroutes to the route processing engine. The route processing enginegenerates an output set of routes and returns the output data to thetable mapping engine, which stores the computed state in the statestorage (and uses the computed state to generate information fordistribution to the managed forwarding elements and gateways. Forpurposes of this section, however, the state computation module 715 istreated as a single entity. The details of the table mapping engine androute processing engine are described in greater detail below in SectionIII.

The operation of the controller 700 to receive configuration state,including static router information, and process that configurationstate will now be described by reference to FIGS. 7-9. FIG. 7conceptually illustrates the receipt of a logical network configuration720 by the controller 700. As shown, the API 705 receives aconfiguration 720 for a logical network through one or more API calls.The logical network, as illustrated, includes two logical switches thatattach to a logical router, which also connects to an external network(e.g., through a L3 gateway port). The logical switches include severalports to which VMs attach. In addition, the logical networkconfiguration 720 indicates that one of the logical router portsconnecting to a switch is assigned the subnet 11.0.0.0/24 and the otherlogical router port connecting to a logical switch is assigned thesubnet 10.0.0.0/24, while the third logical router port connecting to anexternal network is assigned the subnet 18.0.0.0/24.

Though shown as a single set of data 720, in some embodiments the API705 receives separate commands to create each of the logical forwardingelements (logical switch A, logical switch B, and the logical router).In addition, in some embodiments the attachment of each logical switchto the logical router is a separate command, as is the attachment ofeach VM to the logical switch.

The figure also illustrates a portion of the external physical network18.0.0.0/24 to which the logical router gateway port connects.Specifically, the external physical network includes two physicalrouters, with interfaces 18.0.0.1 and 18.0.0.2, respectively, connectingthe logical routers to the physical network 18.0.0.0/24. While shown inthe drawing along with the logical network configuration 720 in order toprovide clarity, one of ordinary skill in the art will recognize thatthe administrator inputting the logical network configuration does notactually input the structure of the physical network. Rather, theadministrator simply configures the logical router gateway port with thesubnet 18.0.0.0/24.

FIG. 7 also shows that the API 705 creates objects 725-735 in the statestorage 710 for the three logical forwarding elements. In someembodiments, the commands received by the API 705 instruct the API tocreate and/or modify these objects. The logical switch objects 730 and735 of some embodiments store a list of logical ports, attachments tothose logical ports, MAC addresses for the logical ports, etc.

As illustrated, the logical router object 725 of some embodimentsincludes its list of ports, two of which attach to the logical switchesA and B, and a third of which attaches to the external network as an L3gateway port. The logical router object 725 may specify whether thelogical router is implemented in distributed or centralized fashion insome embodiments. In addition, the API 705 creates a set of routes 740as part of the logical router object. In some embodiments, each of theroutes is also an object (owned by the logical router object) stored inthe state storage 710. As shown, the set of routes includes routesautomatically generated by the API 705 based on the logical networkconfiguration 720. Specifically, for each of the logical ports(connecting to a logical switch, L3 gateway, etc.), the API 705generates a connected high-priority route for the network address range(e.g., IP addresses) associated with that port.

In this case, one of the routes 745 is for the port to which logicalswitch A attaches. This route 745 routes network addresses that fall inthe range (given in Classless Inter-Domain Routing (CIDR) format)11.0.0.0/24 to the logical output port X. In addition, the route objectof some embodiments specifies the type of route (e.g., connected,because the route is based on a specific logical port), the action totake for packets with destination IP addresses in the prefix range(accept, in this case, though other routes may specify to drop packets),and the priority of the route. In some embodiments, connected routes aregiven the highest priority (1). In addition to the route 745, the set ofroutes also includes a similarly structured route to send IP addressesin the range 10.0.0.0/24 to logical output port Y. In some embodiments,the API 705 also includes a low-priority default route to send packetsto a particular one of the external physical routers (e.g., 18.0.0.2) ifthe IP address is not otherwise recognized. Such a route might specifyto send packets in the range 0.0.0.0/0 to 18.0.0.2, but with a priorityof 10 (or whatever number is used for the lowest priority). Otherembodiments do not specify a priority for the route 0.0.0.0/0, becauseby longest-prefix-matching principles all routes will always be morespecific, and therefore have higher priorities. Such a route would beoverruled by any more specific route, but would serve to send packetsfor unknown destinations to the external network by default.

Though not shown in this figure, the state computation module 715 ofsome embodiments identifies that the configuration state has changed,and subsequently retrieves this data in order to compute stateinformation for distribution to the managed forwarding elements. Thestate computation module 715 generates flow entries and/or data tuplesto distribute to the managed forwarding elements and namespaces, anddistributes this computed information (e.g., via a set of physicalcontrollers). The state computation module 715 also stores the computedstate in the state storage 710.

FIG. 8 conceptually illustrates the receipt by the controller 700 ofconfiguration data for a static route for the logical router 725. Asshown, the API 705 receives a command (or set of commands) to create astatic route 805 with a set of parameters. In this case, the set ofparameters include a logical router identifier, a routed prefix, a nexthop IP address, an action, and a priority. The logical router identifierenables the API to store the route with the appropriate logical router(in this example, the logical router created in FIG. 7). The routedprefix identifies a network address or range of network addresses towhich the route applies (i.e., such that packets having destinationaddresses in the range will be processed according to the route). Thenext hop address specifies a network address to which packets havingdestination addresses in the range of the routed prefix should be sent(18.0.0.1 in this case). Some routes, rather than specifying a next hop,specify an output port of the router (e.g., Port Z). The actionidentifies, in some embodiments, whether to allow a packet through therouter or to drop the packet. Some embodiments only allow for thelogical router to silently drop packets or allow packets, while otherembodiments also allow the logical router to reject packets (drop whilesending a message that the destination is unreachable). Finally, thepriority indicates how the state computation module 715 should rank theroute when performing route traversal on the configuration state routesin order to identify a set of output routes for implementation in thenetwork.

The API 705 of some embodiments generates error messages to return tothe user (or application providing the API calls) if a static route isnot input properly. For instance, if the static route specifies both anext hop IP and an output port, or one of these destinations and a droppacket action, or neither of these destinations with an accept action,then the API returns an error message and does not create the route.Furthermore, the API 705 may send error messages if the specifiedlogical router does not exist, if the user attempts to manually create aconnected route, if any of the network addresses are malformed, or if aroute for the same prefix having the same priority already exists forthe logical router.

Because the input route is correctly specified, the API 705 stores anobject 810 for the static route in the set of routes 740 for the logicalrouter 725, as the static route configuration data 805 identifies thisas the logical router to which the route belongs. As shown, the datastored for the object 810 includes the information input for the routeas configuration data 805: the routed prefix 20.0.0.0/24, the next hopIP address 18.0.0.1, the accept action, and the priority 4 (with 1 beingthe highest priority). In this case, the route specifies a next hop IPaddress of one of the physical routers on the external network to whichthe L3 gateway port Z is attached. The router 18.0.0.1 might haveanother interface that connects to the subnet 20.0.0.0/24, and thereforethe administrator setting up the logical network would indicate via astatic route that packets with those destination addresses should besent to the particular router with the interface 18.0.0.1 (i.e., asopposed to the other router with an interface 18.0.0.2).

FIG. 9 conceptually illustrates computation performed by the networkcontroller 700 based on the static route 810 configured for the logicalrouter 725. When only connected routes (and, possibly, anautomatically-generated default route) are present, some embodiments donot need to compute an output set of routes, as no route traversal isrequired. However, once the user configures static routes for thelogical router, the state computation module(s) 715 may need to evaluatepriority between conflicting routes, identify output ports for routesbased on the specified next hop IP, etc.

As shown in this figure, the state computation module 715 retrieves aset of input routes 905 from the state storage 710 and returns a set ofoutput routes 910 to the state storage. In some embodiments, thecontroller stores a separate set of objects for the output routes ascompared to the objects stored for the input routes. In otherembodiments, the controller stores additional information (e.g., a finalaction, whether the route is in use) for each route in the existingobject for the route. In still other embodiments, the controller storesa set of objects with the additional information that are linked to theinput routes (e.g., a first set of route objects and a second set ofroute status objects, with each route status object owned by a differentroute object).

In this example, the output set of routes 910 is stored with the logicalrouter by the state computation module 715. The operation of the statecomputation module to generate the output set of routes 910 will bedescribed in greater detail below in Section III. As shown, the logicalrouter object 725 now includes output routes, including an output route915 for the input route 810. The output route 915 specifies, for networkaddresses in the range 20.0.0.0/24, that packets should be sent tooutput Port Z, with a final next hop IP address of 18.0.0.1. This isbased on the static route sending packets in the specified range to theIP address 18.0.0.1, which is in the range of addresses that the routersends to Port Z (via a connected route generated based on the logicalnetwork configuration).

In addition to storing this computed state in the storage 710, the statecomputation module 715 also generates updated data to provision the MFEsand gateways based on the updated routes. That is, the state computationgenerates additional data tuples and/or flow entries that incorporatethe added static route, indicating to forward packets with destinationaddresses in the range 20.0.0.0/24 to the logical output port for the L3gateway, to the next hop IP address 18.0.0.1.

One example for which a user might configure static routes occurs when alogical router has multiple output ports connecting to an externalnetwork, which are implemented on different gateways (which mightconnect to different physical routers in the external network). The usermight want packets for a specific external destination sent out eithervia a specific gateway or via a specific external router, and thisinformation could be incorporated into a static route (i.e., specifying,for packets to the destination's network address, the next hop IPaddress of the specific router, or the output port associated with thespecific gateway). Similarly, as in the case shown in FIG. 7, a singlelogical router output port might connect to a physical network withmultiple physical routers, and the user might want packets for differentdestinations sent to the different routers (e.g., if the differentphysical routers have interfaces to different networks).

FIG. 10 conceptually illustrates a process 1000 of some embodiments forreceiving a logical static route, determining whether the route isvalid, and storing the route as configuration state data if valid. Insome embodiments, the process 1000 is performed by a network controller(e.g., by the API of the network controller).

As shown, the process 1000 begins by receiving (at 1005) a command tocreate a new static route for a logical router. In some embodiments, thecontroller receives this through an API call to create a new route,which includes various parameters to define the route. These parametersmay include the logical router for which the route is defined, the IPprefix range of packets that will be routed according to the route, adestination for the route, and a priority for the route (as well asother parameters, in some cases).

Upon receiving the route, the process determines (at 1010) whether theparticular logical router for which the route is specified exists. Insome embodiments, the parameters specify a logical router for the routeby a unique identifier. The logical router, however, must actually be alogical router for which data is stored at the controller. In someembodiments, this does not require that the controller be the master ofthe logical router (i.e., that the controller compute state for thelogical router), as the configuration state for the logical router maybe shared between the controllers. Thus, the process 1000 could beperformed to receive static route information for a logical router at acontroller that is not the master controller of the logical router, asthe receiving controller would share the data with the mastercontroller, which could then compute additional state information forthe logical router based on the received data.

When the logical router specified in the logical route parameters doesnot exist, the process proceeds to 1035, which is described below.Otherwise, the process 1000 identifies (at 1015) the prefix to be routedby the static route. This is the range of destination network addresses(e.g., IP addresses) to which the route will be applied (i.e., the routewill be applied to packets having a destination network address in therange specified by the prefix.

The process then determines (at 1020) whether the identified prefix isvalid. In some embodiments, a valid prefix is one formatted in properCIDR format (i.e., four 8-bit numbers, with a number of leading bits ofthe prefix). Thus, a prefix range of X.Y.Z.0/24 specifies any networkaddress from X.Y.Z.0-X.Y.Z.255. Similarly, a prefix range of X.Y.Z.0/28specifies any network address from X.Y.Z.0-X.Y.Z.127. A prefix isinvalid if any of the specified numbers is greater than 8 bits (e.g., ifthe user attempts to specify 257.0.0.0), if more than four numbers aregiven, etc.

When the prefix specified for the route is invalid, the process proceedsto 1035, described below. Otherwise, the process 1000 identifies (at1025) a destination for the route. The process then determines (at 1030)whether the destination is exactly one of a next hop network address, anoutput port, or a silent drop. Some embodiments actually specify thesedestinations as part of different parameters. For instance, in someembodiments, the static route definition allows for separate outputport, next hop IP, and action parameters. The output port is used if thepackets with destination addresses matching the specified prefix shouldbe sent to a particular port of the logical router. The next hop IPaddress is used if the packets with destination addresses matching thespecified prefix should be sent to, e.g., a particular different router(e.g., a physical router on an external network). Some embodimentsrequire that an action be specified for the route, with possible optionsof accept and blackhole (i.e., silently drop, without sending an errormessage to the sender).

Some embodiments do not allow the configuration for a static route tospecify both an output port and a next hop network address. Furthermore,when the specified action is to accept packets with destinationaddresses in the prefix range, exactly one of the output port and thenext hop address must be specified. On the other hand, when the actionspecifies to drop packets, then both of the output port and the next hopaddress must be empty.

When one of these conditions is violated (e.g., more than one of silentdrop, a next hop address, and an output port are specified, or none ofthese are specified), the process 1000 returns (at 1035) an error. Asindicated above, an error may be returned for invalid prefixes ornonexistent logical routers, as well. Some embodiments return an errormessage to the source of the command (e.g., a management application, anadministrator computer, etc.) that attempted to create the new route.

When the route is a valid static route, the process 1000 stores theroute as an input route for the specified logical router. In someembodiments, the process creates a new route object for the staticroute, which is owned by a previously-created logical router object.Storing the new route, in some embodiments, automatically causes thecontroller to perform a route traversal process for the logical router(or, at least for the new route of the logical router) in order toidentify whether to use the route, and other output information for theroute. Furthermore, in some embodiments, the controller automaticallyshares the configured route (i.e., the input route) with othercontrollers, in case those controllers need to use the route to computestate information.

III. Route Processing by Controller

As indicated above, the network controller of some embodiments performsroute processing operations to generate an output set of routes from aninput set of routes for a logical router. Specifically, when new routesare configured for a logical router (e.g., new static routes inputmanually through commands to the controller, new connected routesgenerated based on the attachment of logical switches to ports of thelogical router, etc.), some embodiments use a route processing engine inthe controller to calculate the set of output routes. The routeprocessing engine identifies final actions (e.g., a final output port, adrop action) for each routed prefix, identifies routes that should betaken out of use based on superseding higher-priority routes, andperforms other actions. In some embodiments, a table mapping engine inthe controller uses the data from the route processing engine togenerate data tuples for distribution to network elements (e.g., managedforwarding elements, namespaces that implement L3 gateways).

FIG. 11 conceptually illustrates a network controller 1100 of someembodiments, and the data flow through the controller as the controllerperforms route processing operations. The network controller 1100includes an API 1105, a state storage 1110, a table mapping engine 1115,a route processing engine 1120, and a state distribution interface 1125,similar to the network controller 100 described above.

The API 1105 of some embodiments provides an interface through which thecontroller receives configuration state data for one or more logicalnetworks. As described above by reference to FIG. 7, in some embodimentsthe API 1105 represents a set of methods that may be used to create,modify, delete, query, etc. logical network data in the state storage1110. In some embodiments, a network administrator may access thecontroller through a direct connection (e.g., by manually inputting theAPI calls) or through a cloud management application. Some such APImethods for the API 1105 include methods to create a logical router,create logical router ports, create a logical switch, attach a logicalswitch to a logical router, attach a logical port to an externalnetwork, create a static route, modify a static route, remove a staticroute, query a logical router for its routes, etc. These variousmethods, in some embodiments, enable the administrator to access ormodify configuration state data for logical routers stored in the statestorage 1110.

In some embodiments, the state storage 1110 stores a set of objects thatdefine logical networks managed by the controller 1100, as well asconfiguration state for logical networks managed by other networkcontrollers. Based on commands received by the API 1105, the controller1100 creates, modifies, and deletes objects in the state storage 1110.In addition to storing the configuration state received through the API1105, the state storage of some embodiments also stores computed statecalculated by the state computation module 1115. Furthermore, thenetwork controller 1100 may receive state information from other networkcontrollers and network elements (e.g., MFEs, gateways operating innamespaces), as described above by reference to FIG. 7.

The table mapping engine 1115 performs state calculations for logicalnetworks managed by the controller 1100. As shown, the table mappingengine 1115 includes a flow generation module 1130 and a configurationdata generation module 1135, both of which generate data fordistribution to the managed forwarding elements and L3 gateways. In someembodiments, both of these modules use similar input data tuples togenerate output data tuples, but generate different data fordistribution to the various network elements.

The flow generation module 1130 generates data for the managedforwarding elements to use in processing packets. Specifically, in someembodiments the flow generation module 1130 generates flow entries thattake a match-action format. That is, each flow entry specifies acondition or set of conditions for a packet to match and an action orset of actions for a managed forwarding element to apply to the packetwhen the packet matches all of the conditions. For instance, one of manyflow entries used to implement a logical router might specify that if apacket (i) has been assigned to the logical router and (ii) has adestination IP address in a particular range (e.g., 10.0.0.0/24), thentake the actions of (i) writing a particular logical egress port into aregister for the packet and (ii) resubmit the packet to the managedforwarding element for further processing. In some embodiments, the flowgeneration module 1130 generates the flow entries by performing tablemapping operations (e.g., join operations) on the data stored in thestate storage 1110, as well as information received from the routeprocessing engine 1120. In some embodiments, the flow generation module1130 of the table mapping engine 1115 outputs data for distribution viathe OpenFlow protocol.

The configuration data generator 1135 generates data for both themanaged forwarding elements as well as the namespaces in which logicalrouters and L3 gateways operate, in some embodiments. For the managedforwarding elements, the configuration data may include port and/ortunnel configuration, among other data. Whereas the MFEs receive packetprocessing data as flow entries, however, the namespaces that implementcentralized logical routers and L3 gateways for distributed logicalrouters receive packet processing instructions in the format of datatuples distributed in the same manner as configuration data. Forinstance, for a namespace, the gateway host machine on which thenamespace resides receives the definition of the namespace as a datatuple generated by the configuration data generator 1135, and receivesits routing table and other network stack configuration in this formatas well, in some embodiments. As with the flow generation module 1130,the configuration data generator 1135 of some embodiments generatesconfiguration data by performing table mapping operations (e.g., joinoperations) on the data stored in the state storage 1110, as well asinformation received from the route processing engine 1120. In someembodiments, the configuration data generator 1135 outputs data fordistribution via the OVSDB protocol.

The route processing engine 1120 of some embodiments receives a set ofroutes from the table mapping engine 1115 (e.g., routes automaticallygenerated based on the subnets to which the logical ports of the logicalrouter connect, static routes received through the API 1105) andperforms a recursive traversal process on the routes in order toidentify a final logical destination for each network address rangerouted by the logical router. When multiple input routes providecontradictory information for a particular network address or range ofaddresses, the route processing engine 1120 of some embodimentsdetermines which route has a higher priority. Some input routes mayprovide a next hop address rather than output port for a route. In thesecases, the route processing engine recursively traverses the set ofinput routes until reaching a route specifying either a destinationoutput port or a drop packet action. The route processing engine 1120returns the set of output routes, with final actions (e.g., drop packet,send to particular output port) specified for each route. In someembodiments, the route processing engine 1120 is implemented in alanguage different from the table mapping engine 1115 (i.e., not a tablemapping language). Specifically, some embodiments implement the routeprocessing engine in a language that is optimal for error checking andrecursive traversal processes (e.g., C, C++ etc.).

The controller 1100 distributes the flow entries and configuration datafor the logical router (and other data for, e.g., other logicalforwarding elements, such as the logical switches of the logicalnetwork) generated by the table mapping engine 1115 to host machines viathe state distribution interface 1125. The host machines shown in thefigure include a first machine 1140 for hosting VMs and a second machine1145 for hosting namespaces to implement logical routers and gateways.Both of the host machines 1140 and 1145 include managed forwardingelements for processing packets (e.g., OVS), while the gateway host 1145also includes the logical routers and gateways to act as routers inorder to process packets.

In some embodiments, the controller 1100 distributes the data through ahierarchy of other network controllers, as shown above in FIG. 5. Insuch embodiments, the state distribution interface is an interface withother controllers that act as intermediaries for the distribution ofdata to the host machines (and possibly perform additional translationof the data tuples). In some embodiments, the controller 1100 uses aRemote Procedure Call (RPC) channel to communicate with othercontrollers.

In other embodiments, the controller 1100 interfaces directly with thehost machines 1140 and 1145 (as well as numerous other host machines) todistribute the data. In some such embodiments, the controller uses twochannels for communication with each host machine: a first channel(e.g., OpenFlow) for distributing the flow entries generated by the flowentry generation module 1130 for use by the managed forwarding elements,and a second channel (e.g., OVSDB) for distributing the configurationdata generated by the configuration data generator 1135.

The data flow through the network controller 1100 during its operationto process logical router information will now be described. FIG. 11includes several encircled numbers, which indicate the flow of differentdata into, through, and out of the network controller 1100. One ofordinary skill in the art will recognize that the controllers of someembodiments will process data other that that which is shown, and thatthe data flow in this figure is meant to represent the operationsperformed and data transferred specifically relating to a logical routermanaged by the network controller.

As shown by the encircled 1, the API 1105 receives a command to createor modify the configuration of a logical router. Specifically, thecommand modifies the routes stored for the logical router. The commandcould be the creation of a new static route, the attachment of a logicalswitch to a port of the logical router, the creation of a new port forthe logical router, the modification of an existing static route, etc.

As a result, shown by the encircled 2, the API 1105 modifies the datastructure 1150 stored for the logical router (e.g., an object, such as aC++ object) in the state storage 1110. The figure illustratively showsthe logical router data structure 1150 as storing a RIB (set of inputroutes) and FIB (set of output routes). While some embodiments use sucha structure, other embodiments store data structures (e.g., objects) foreach input route, owned by the logical router. After processing, in somesuch embodiments the logical router also stores a status data structure(e.g., object) for each route. Other such embodiments modify the routedata structure after processing to include the status data. Thisprocessing will be described in further detail below.

In this example, the configuration state of the logical router 1150 ismodified based on data received through the API 1105 of the controller1100. However, in some embodiments, this configuration data couldinstead be received by another controller in the network control system.In this case, the other controller receives the data and updates itscopy of the logical router data structure. However, because the othercontroller does not manage the particular logical router, the controllerdoes not compute additional state based on the input state. The othercontroller does, though, propagate the modified configuration state toother controllers, including the controller 1100. In this situation,when the controller 1100 receives the update to the logical router datastructure 1150, the controller 1100 proceeds as shown by the remainderof the figure.

When the configuration state of the logical router data structure 1150is modified, the table mapping engine 1115 retrieves the state of thelogical router, as shown by the encircled 3 in the figure. For changesto other data structures, and for some changes to the logical router,the table mapping engine begins computing additional state at thispoint. However, because the update to the logical router modifies theconfiguration state routes of the data structure, the table mappingengine 1115 passes the route data to the route processing engine 1120,as shown by the encircled 4.

The route processing engine 1120 performs a route selection andtraversal operation in order to identify the output routing table forthe logical router. The operation of the route processing engineaccording to some embodiments is shown by FIGS. 12A and 12B. In someembodiments, the route processing engine 1120 takes as input each new ormodified route for the logical router, and outputs status data for eachroute. For instance, for a new static route that specifies a next hop IPaddress, the route processing engine determines whether to use the newroute and, if in use, a final output port for the route or a finalaction of blackhole (i.e., drop packets) for the route. The routeprocessing engine 1120 returns the output set of routes to the tablemapping engine 1115, as shown by the encircled 5.

At this point, the table mapping engine 1115 performs several actions.The output routing data computed by the route processing engine isstored in the logical router data structure 1150, as shown by theencircled 6. This figure conceptually illustrates this data as beingstored in the FIB. The conceptual RIB for input configuration data andFIB for output data represent analogies to the RIB to FIB conversionperformed by physical routers in traditional networks.

The table mapping engine 1115 also generates both flow entries andconfiguration data using the output routing data provided by the routeprocessing engine 1120. For distributed logical routers, much of therouting for packets sent by VMs of the logical networks is performed bythe first-hop MFEs, using the flow entries. As such, these flow entriesuse the routing data to encode the routes in a match-action format.Thus, a route specifying that a particular network address range isrouted to a particular logical port will be encoded as a match on thedestination address over the network address range and an action to sendthe packet to the logical port. Similarly, a route specifying that aparticular network address range is to be blackholed will be encoded asa match on the destination address over the network address range and anaction to drop the packet. In some cases, the logical router alsospecifies other data (e.g., routing policies, etc.) which the tablemapping engine 1115 encodes in flow entries as well. Because the MFEsoperate on both the VM hosts and the gateway hosts, the table mappingengine distributes the flow entries to both the host 1140 and the host1145 through the state distribution interface 1125, as shown by theencircled 7s (though at least some of the flow entries distributed willbe different between the two hosts).

In addition, the table mapping engine 1115 uses the output routing datafrom the route processing engine 1120 to generate configuration data forthe namespace operating as a L3 gateway on the host 1145. Thisconfiguration data, in some embodiments, (i) defines the existence ofthe namespace and (ii) provides configuration information for thenetwork stack in the namespace, including the routing table. Thus, theoutput routing data from the route processing engine 1120 is used togenerate a set of data tuples defining a routing table for the namespacethat implements a L3 gateway for the logical router. This data isdistributed to the gateway host 1145 through the state distributioninterface 1125, as shown by the encircled 8. As described above, boththe flow entry data tuples and the configuration data tuples may bedistributed through a hierarchy of network controllers rather thandirectly from the controller 1100 to the host machines 1140 and 1145(e.g., through two different network controllers that manage the twodifferent host machines 1140 and 1145).

The above described the data flow through a controller for logicalrouter processing according to some embodiments. As mentioned, one ofthe operations performed on the data involves the route processingengine, which receives a set of input routes and outputs a set of outputroutes (or output routing table data about the input routes). FIGS.12A-B conceptually illustrate a process 1200 performed by the routeprocessing engine of some embodiments to generate a set of output routeinformation for a set of input routes of a logical router. The process1200 will be described by reference to FIGS. 13-16, which conceptuallyillustrate various example input and output sets of route information.

As shown, the process begins by receiving (at 1205) a set of inputroutes from the table mapping engine. As mentioned, the route processorthat performs the process 1200 is, in some embodiments, a separate setof code from the table mapping engine that performs the bulk of thestate computation for the network controller. The table mapping engineaccesses the stored state data for a logical router (e.g., the set ofroute objects), determines when the route processing engine shouldprocess the state data, and passes the data to the route processingengine. In some embodiments, each route in the set of routes is anobject that stores a set of parameters, including the type (e.g.,connected or static), a prefix (i.e., a range of network addresses), anoutput port (i.e., the logical router port to which packets matching theprefix will be sent), a next hop address (i.e., the IP address of thenext hop router or gateway to which packets matching the prefix will besent), an action (e.g., accept (allow packets matching the prefix) orblackhole (drop packets matching the prefix)), and a priority (used toselect between routes for the same network address).

To perform route processing, the process 1200 of some embodiments firstidentifies routes that are superseded by higher priority routes.Different embodiments may perform different sets of operations toidentify low priority routes that should not be used, and only onepossible set of operations is shown in this figure. In the exampleshown, the process 1200 selects one route at a time, then identifies allof the routes that should be removed from use based on having a lowerpriority than the selected route. Other embodiments might select oneroute at a time and then determine whether any other routes eliminatethe selected route from use based on having a higher priority.

In this case, the process 1200 selects (at 1210) a route. Someembodiments start with the highest priority routes or the lowestpriority routes, use a random or pseudo-random order, start with theearliest or latest-created routes, etc. For the selected route, theprocess determines (at 1215) whether any of the other input routes havethe same network address range specified by their prefix as thecurrently selected route. In some embodiments, only routes that have thesame network address range are identified at operation 1215. That is,routes with overlapping prefixes of different specificity are notidentified. That is, a first route for the prefix 12.0.0.1/28 has itsentire network address range encompassed by a second route for theprefix 12.0.0.0/24. However, even if the 12.0.0.0/24 route has a higherpriority, the first route will not be removed. This is because thelogical routers of some embodiments use longest prefix matchingprinciples. Thus, a more specific route (e.g., a “/28” route) has aninherently higher priority than a less specific route (e.g., a “/24”route). Packets matching two routes of different specificities will berouted by the more specific route, irrespective of the listed prioritiesof the routes.

If any routes exist in the input routes with the same prefix as theselected route, the process marks (at 1220) all of the routes for theprefix, except the highest priority route, as not in use. This indicatesthat the network controller will not use the route when generating datatuples to implement the logical router. In this way, the routeprocessing engine decreases the number of routes actually implemented inthe network when the routes will not have any bearing on the processingof packets.

FIG. 13 conceptually illustrates an example set of input routes 1300 andthe output set of routes 1350 for the input routes 1300, in which a lowpriority route is superseded by a higher-priority route. The input setof routes 1300 includes four routes 1310-1340. The first and secondroutes 1310 and 1320 are connected routes, based on the configuration ofports (associated with subnets 10.0.0.0/24 and 11.0.0.0/24,respectively) of the logical router (ports Y and X, respectively). Thesetwo routes have the highest priorities, being automatically-createdconnected routes. The third route 1330 is a static route created to actas a default route for packets that do not match any other route. Theroute has the lowest possible priority, which in this case is 10(although other embodiments may use different ranges of priorities, suchas 1 to 100, 1 to 250, etc.), although because the prefix has the lowestpossible specificity, the priority does not matter unless multipleroutes are created configured for entire possible range of IP addresses.Finally, the fourth route 1340 is a route for the prefix 11.0.0.0/24,forwarding packets with destination addresses in that range to the nexthop router at IP 12.0.0.1. The route 1340 has a priority of 5. As shownby the output routing data 1350, the first three routes 1310-1330 havebeen marked as in use, while the route 1340 has been marked as not inuse due to low priority. This occurs because the range of networkaddresses for which the route 1320 is the same as the range of networkaddresses for which the route 1340 is specified.

After marking any low priority routes that are superseded by theselected route as not in use, the process determines (at 1225) whetherthe set of input routes contains any additional routes to check forsuperseded lower-priority routes. When a route is marked as not in use,some embodiments remove the route from the set of input routes toanalyze with operations 1210-1220. When more routes remain for analysisby these operations, the process returns to 1210 to select anotherroute.

Once all of the routes have been processed to remove low priorityroutes, the route processing engine then removes routes that sendpackets to ports that are not in use. For this, the process 1200 selects(at 1230) a route that is in use (i.e., that has not been marked as notin use) and specifies an output port. As with operation 1210, differentembodiments may select the routes in an order based on priority, time ofcreation, etc. In this case, though, only routes that specify adestination output port (i.e., a port of the logical router) areselected. As described above, routes may either specify a destinationoutput port, a destination next hop IP address, or a drop action, butnot more than one of these. For this operation, the route processingengine is only interested in the routes that specify destination outputports.

For the selected route, the process determines (at 1235) whether theport exists and is currently up. In some cases, the route may specify asits destination a logical port that does not exist. For instance, a usermight create a logical router with six ports, and then create a staticroute pointing to the fifth port. If the user then modifies the logicalrouter to remove the fifth and sixth ports, the static route will pointto a non-existent port. Furthermore, a port might not be in use. If, inthe previous example, the user does not attach the fifth port to anydestinations (e.g., an external network, a logical switch, etc.), thenthe port will not be in use.

If the selected route specifies as a destination an output logical portthat either does not exist or is down (not in use), then the process1200 marks (at 1240) the selected route as not in use. This indicatesthat the network controller will not use the route when generating datatuples to implement the logical router. This prevents the implementationof the logical router from sending packets to logical ports that do notmap to a physical destination.

FIG. 14 conceptually illustrates an example set of input routes 1400 andthe output set of routes 1450 for the input routes 1400, in which routespecifies an output port that does not exist. The input set of routes1400 includes four routes 1410-1440. The first and second routes 1410and 1420 are connected routes, based on the configuration of ports(associated with subnets 10.0.0.0/24 and 11.0.0.0/24, respectively) ofthe logical router (ports Y and X, respectively). The third route 1430is a static route created to act as a default route for packets that donot match any other route. Finally, the fourth route 1440 is a staticroute for the prefix 12.0.0.0/28, specifying an output port Q. However,the port Q does not exist for the logical router for which the routes1410-1440 are defined. As shown by the output routing data 1450, thefirst three routes 1410-1430 have been marked as in use, while the route1440 has been marked as not in use due to the port not existing.Similarly, if the port Q was not currently in use, the route 1440 wouldbe marked as not in use due to the port not being in use. In this case,if the user created a port Q for the logical router, and attached theport Q to a destination, then the route processing engine wouldre-evaluate the routes and classify the route 1340 as in use.

After evaluating each route specifying an output port, the process 1200determines (at 1245) whether the set of input routes in use includes anyadditional routes that specify output port destinations. When more suchroutes exist, the process returns to 1230 to select the next such route.After checking all of the routes that specify output ports, the process1200 then begins the recursive route traversal operations. Theseoperations, for each route, identify either a destination output port ora drop action, based on following the paths specified by the set ofroutes.

As shown, the process selects (at 1250) a route that is in use (i.e.,not superseded by a higher-priority route) and specifies a next hopdestination IP address (rather than a drop packet action or an outputport destination). Similar to operations 1210 and 1230, differentembodiments select the routes in a different order.

For the selected route, the process looks up (at 1255) a route for thespecified destination next hop IP address. So long as a default route(for the prefix 0.0.0.0/0) is included in the input set of routes, thenall IP addresses will match at least one route. If the IP address mapsto the prefixes of multiple routes, then operation 1255 uses the routewith the longest prefix match in some embodiments. For instance, if theselected route specifies a next hop IP of 20.1.1.1, and routes exist forthe prefixes 20.0.0.0/8 and 20.1.1.0/24, the route processor uses theroute for the more specific prefix 20.1.1.0/24.

The process 1200 then determines (at 1260) whether the route identifiedfor the next hop IP is in use. In general, the routes are in use bydefault unless marked as not in use for either low priority or aport-related issue (the port being down or nonexistent). In this case,lower priority routes will not be identified for a next hop IP, becausethe higher-priority route will always be an option. When thehighest-priority (and most specific) route identified for the next hopis not in use, then the process marks (at 1265) the selected route asnot in use, and proceeds to operation 1295 to determine whetheradditional routes require the route traversal process.

Otherwise, if the route for the next hop IP is still in use, the processdetermines (at 1270) whether the route for the next hop IP address isset to drop packets. As mentioned, some routes may specify a drop packetaction rather than an accept packet action with a destination. If theidentified route for the next hop is set to drop packets, the process1200 sets (at 1275) the currently selected route (selected at operation1250) to also drop packets and clears (at 1280) the previously specifiednext hop IP for the selected route, then proceeds to operation 1295.Because some embodiments do not allow a route to specify a destination(e.g., a next hop IP address) and specify to drop packets, when theroute processor sets the drop packet action for a route, the routeprocessor also removes the next hop IP for the route in order to satisfythese criteria. In some embodiments, the route processor does not modifythe route object, but rather a route status object that specifies theoutput settings for the route to be used by the table mapping engine togenerate data tuples for implementation of the logical router. In somesuch embodiments, the route processor sets a final action parameter forthe route status to drop packets and clears a final next hop IPparameter, but does not change the configured route data.

If the identified route for the next hop IP does not specify a droppacket action, the process then determines (at 1285) whether the routeidentified for the next hop IP address specifies an output portdestination. At this point, the route identified at operation 1255either specifies (i) another next hop IP address or (ii) an output portas its destination, as it does not specify a drop packet action.

When the identified route does not specify an output port destination(i.e., specifies another next hop IP address), the process returns tooperation 1255 to look up a route for the next hop IP address specifiedby the route identified at the previous iteration of operation 1255.Thus, if a first route for the prefix 13.0.0.0/24 specifies a next hopgateway IP of 14.0.0.1, and a second route for the prefix 14.0.0.0/24specifies a next hop gateway IP of 15.0.0.1, then the route processorlooks up a third route for 15.0.0.1 and attempts to use the specifiedaction or destination for this route to resolve the first route. Theprocess continues recursively attempting to resolve the routes until itreaches a route that (i) not in use, (ii) specifies a drop action, or(iii) specifies an output port.

When the most recently identified route specifies an output port as itsdestination, the process sets (at 1290) the final output port of theselected route as the output port specified by the most recentlyidentified route. In addition, the process sets the current next hop IP(i.e., the next hop IP for which the most recently identified route wasidentified) as the final next hop IP for the selected route (i.e., theroute selected at operation 1250).

FIGS. 15 and 16 conceptually illustrate two different example sets ofinput routes and the output sets of routes for these input routes afterthe route traversal process is performed. FIG. 15 illustrates an inputset of routes 1500 that includes five routes 1510-1550. The first threeroutes (two connected routes 1510 and 1520, and a default route 1530)are the same as in the previous examples of FIGS. 13 and 14. The fourthroute 1540 is for the prefix 13.0.0.0/24, and specifies an accept actionwith a next hop IP address of 12.0.0.1. The fifth route 1550 is for theprefix 12.0.0.0/24, and specifies a next hop IP address of 11.0.0.1.

As the first two routes 1510-1530 specify output ports as theirdestinations, these routes are simply marked as in use in the output setof routes 1560, and no traversal is required. In some embodiments,though not shown in this figure for simplicity, the route processorcopies the output ports into a final output port route status field foreach of these routes 1510-1530, and similarly copies the action of‘accept’ into a final action status field for the routes. For the route1540, the route traversal process first looks up a route for the nexthop IP address of 12.0.0.1, and identifies the route 1550. Because thisroute specifies a next hop IP destination of 11.0.0.1, the routetraversal process next looks up a route for this IP address, andidentifies the route 1520. At this point, the newly identified routespecifies an output port, so this output port X and the final next hopIP address (11.0.0.1) are copied into the final status data for theoutput route 1540. For the route 1550, the route traversal processinvolves fewer recursive lookups, as the first route identified is theroute 1520, which specifies the output port X. As such, the output route1540 includes the final output port X. In some embodiments, the routeprocessor also copies the next hop IP 11.0.0.1 into a final next hop IPfield for the output. The default route 1530 specifies a next hop IP10.0.0.1, which resolves to Port Y after the recursive route traversal.

FIG. 16 illustrates an input set of routes 1600 that includes fiveroutes 1610-1650. The first four routes 1610-1640 are the same as in theprevious example of FIG. 15. However, the fifth route 1550 specifies ablackhole (drop packet) action for the prefix 12.0.0.0/24, rather than anext hop IP address or output port. As such, for the route 1640, theroute traversal process first looks up a route for the next hop IPaddress of 12.0.0.1, and identifies the route 1650. This route specifiesa blackhole action rather than a next hop IP or output port, andtherefore the traversal process identifies at this point that the finalaction for the route 1640 is to drop packets, and copies the blackholeaction into the final action for the output route 1640.

Returning to the process 1200, after a selected route has been resolvedand any needed output data generated for the route, the processdetermines (at 1295) whether any additional routes remain that requirethe route traversal process (i.e., are not marked as not in use, andspecify a next hop IP address). When additional routes remain, theprocess returns to 1250 to select another route for traversal. Once allof the routes have been analyzed and the output data generated for theroutes, the process 1200 returns (at 1297) the output set of routes tothe table mapping engine, so that the table mapping engine can use theoutput status data to generate the data tuples used by the MFEs andgateways to implement the logical router.

IV. Electronic System

Many of the above-described features and applications are implemented assoftware processes that are specified as a set of instructions recordedon a computer readable storage medium (also referred to as computerreadable medium). When these instructions are executed by one or moreprocessing unit(s) (e.g., one or more processors, cores of processors,or other processing units), they cause the processing unit(s) to performthe actions indicated in the instructions. Examples of computer readablemedia include, but are not limited to, CD-ROMs, flash drives, RAM chips,hard drives, EPROMs, etc. The computer readable media does not includecarrier waves and electronic signals passing wirelessly or over wiredconnections.

In this specification, the term “software” is meant to include firmwareresiding in read-only memory or applications stored in magnetic storage,which can be read into memory for processing by a processor. Also, insome embodiments, multiple software inventions can be implemented assub-parts of a larger program while remaining distinct softwareinventions. In some embodiments, multiple software inventions can alsobe implemented as separate programs. Finally, any combination ofseparate programs that together implement a software invention describedhere is within the scope of the invention. In some embodiments, thesoftware programs, when installed to operate on one or more electronicsystems, define one or more specific machine implementations thatexecute and perform the operations of the software programs.

FIG. 17 conceptually illustrates an electronic system 1700 with whichsome embodiments of the invention are implemented. The electronic system1700 can be used to execute any of the control, virtualization, oroperating system applications described above. The electronic system1700 may be a computer (e.g., a desktop computer, personal computer,tablet computer, server computer, mainframe, a blade computer etc.),phone, PDA, or any other sort of electronic device. Such an electronicsystem includes various types of computer readable media and interfacesfor various other types of computer readable media. Electronic system1700 includes a bus 1705, processing unit(s) 1710, a system memory 1725,a read-only memory 1730, a permanent storage device 1735, input devices1740, and output devices 1745.

The bus 1705 collectively represents all system, peripheral, and chipsetbuses that communicatively connect the numerous internal devices of theelectronic system 1700. For instance, the bus 1705 communicativelyconnects the processing unit(s) 1710 with the read-only memory 1730, thesystem memory 1725, and the permanent storage device 1735.

From these various memory units, the processing unit(s) 1710 retrieveinstructions to execute and data to process in order to execute theprocesses of the invention. The processing unit(s) may be a singleprocessor or a multi-core processor in different embodiments.

The read-only-memory (ROM) 1730 stores static data and instructions thatare needed by the processing unit(s) 1710 and other modules of theelectronic system. The permanent storage device 1735, on the other hand,is a read-and-write memory device. This device is a non-volatile memoryunit that stores instructions and data even when the electronic system1700 is off. Some embodiments of the invention use a mass-storage device(such as a magnetic or optical disk and its corresponding disk drive) asthe permanent storage device 1735.

Other embodiments use a removable storage device (such as a floppy disk,flash drive, etc.) as the permanent storage device. Like the permanentstorage device 1735, the system memory 1725 is a read-and-write memorydevice. However, unlike storage device 1735, the system memory is avolatile read-and-write memory, such a random access memory. The systemmemory stores some of the instructions and data that the processor needsat runtime. In some embodiments, the invention's processes are stored inthe system memory 1725, the permanent storage device 1735, and/or theread-only memory 1730. From these various memory units, the processingunit(s) 1710 retrieve instructions to execute and data to process inorder to execute the processes of some embodiments.

The bus 1705 also connects to the input and output devices 1740 and1745. The input devices enable the user to communicate information andselect commands to the electronic system. The input devices 1740 includealphanumeric keyboards and pointing devices (also called “cursor controldevices”). The output devices 1745 display images generated by theelectronic system. The output devices include printers and displaydevices, such as cathode ray tubes (CRT) or liquid crystal displays(LCD). Some embodiments include devices such as a touchscreen thatfunction as both input and output devices.

Finally, as shown in FIG. 17, bus 1705 also couples electronic system1700 to a network 1765 through a network adapter (not shown). In thismanner, the computer can be a part of a network of computers (such as alocal area network (“LAN”), a wide area network (“WAN”), or an Intranet,or a network of networks, such as the Internet. Any or all components ofelectronic system 1700 may be used in conjunction with the invention.

Some embodiments include electronic components, such as microprocessors,storage and memory that store computer program instructions in amachine-readable or computer-readable medium (alternatively referred toas computer-readable storage media, machine-readable media, ormachine-readable storage media). Some examples of such computer-readablemedia include RAM, ROM, read-only compact discs (CD-ROM), recordablecompact discs (CD-R), rewritable compact discs (CD-RW), read-onlydigital versatile discs (e.g., DVD-ROM, dual-layer DVD-ROM), a varietyof recordable/rewritable DVDs (e.g., DVD-RAM, DVD-RW, DVD+RW, etc.),flash memory (e.g., SD cards, mini-SD cards, micro-SD cards, etc.),magnetic and/or solid state hard drives, read-only and recordableBlu-Ray® discs, ultra density optical discs, any other optical ormagnetic media, and floppy disks. The computer-readable media may storea computer program that is executable by at least one processing unitand includes sets of instructions for performing various operations.Examples of computer programs or computer code include machine code,such as is produced by a compiler, and files including higher-level codethat are executed by a computer, an electronic component, or amicroprocessor using an interpreter.

While the above discussion primarily refers to microprocessor ormulti-core processors that execute software, some embodiments areperformed by one or more integrated circuits, such as applicationspecific integrated circuits (ASICs) or field programmable gate arrays(FPGAs). In some embodiments, such integrated circuits executeinstructions that are stored on the circuit itself.

As used in this specification, the terms “computer”, “server”,“processor”, and “memory” all refer to electronic or other technologicaldevices. These terms exclude people or groups of people. For thepurposes of the specification, the terms display or displaying meansdisplaying on an electronic device. As used in this specification, theterms “computer readable medium,” “computer readable media,” and“machine readable medium” are entirely restricted to tangible, physicalobjects that store information in a form that is readable by a computer.These terms exclude any wireless signals, wired download signals, andany other ephemeral signals.

While the invention has been described with reference to numerousspecific details, one of ordinary skill in the art will recognize thatthe invention can be embodied in other specific forms without departingfrom the spirit of the invention. In addition, a number of the figures(including FIGS. 10 and 12) conceptually illustrate processes. Thespecific operations of these processes may not be performed in the exactorder shown and described. The specific operations may not be performedin one continuous series of operations, and different specificoperations may be performed in different embodiments. Furthermore, theprocess could be implemented using several sub-processes, or as part ofa larger macro process. Thus, one of ordinary skill in the art wouldunderstand that the invention is not to be limited by the foregoingillustrative details, but rather is to be defined by the appendedclaims.

1-20. (canceled)
 21. For a first module of a network controller thatgenerates configuration data for at least one managed forwardingelement, a method comprising: receiving configuration input for alogical router, the configuration data comprising a first set of routesfor the logical router; offloading a route traversal process to aseparate second module of the network controller, wherein the routetraversal process returns a second set of routes; and generating a setof configuration data for configuring the at least one managedforwarding element to implement the logical router based on the secondset of routes.
 22. The method of claim 21, wherein the route traversalprocess is a recursive route traversal process.
 23. The method of claim21, wherein the first module is a table mapping engine implemented in atable mapping language and the second module is a route processingengine implemented in an object-oriented programming language.
 24. Themethod of claim 21, wherein each route in the first set of routesspecifies one of (i) a next hop network address, (ii) an output port,and (iii) a drop packet action for packets with network addresses in anetwork address range for which the route is defined.
 25. The method ofclaim 24, wherein, to perform the route traversal process, the secondmodule (i) removes from the second set of routes all routes for aparticular network address range other than a highest priority route forthe particular network address range, when the first set of routescomprises multiple routes for a particular network address range, (ii)removes from the second set of routes any route in the first set ofroutes that specifies an output port that does not exist or that is notin use, and (iii) identifies, for each route in the first set of routesthat specifies a next hop network address, one of an output port and adrop packet action by traversing the first set of routes based on thenext hop network address.
 26. The method of claim 21, wherein the set ofconfiguration data is a first set of configuration data, the methodfurther comprising generating a second set of configuration data basedon configuration input received for a logical switch, without using anydata generated by the route processing engine.
 27. The method of claim26, wherein the network controller is a first network controller,wherein the configuration input for the logical switch is receivedthrough an interface with a second network controller.
 28. The method ofclaim 21, wherein the managed forwarding elements comprise L3 gatewaysimplemented at gateway host machines in order to connect a logicalnetwork, to which the logical router belongs, to an external network.29. The method of claim 21, wherein the managed forwarding elementscomprise first-hop managed forwarding elements that operate invirtualization software of a plurality of host machines at which virtualmachines that communicate through a logical network are hosted, whereinthe logical router is one of a set of logical forwarding elements of thelogical network.
 30. The method of claim 21, wherein the configurationinput is received through a set of application programming interfaces ofthe network controller.
 31. A non-transitory machine readable mediumstoring a first module of a network controller which when executed by atleast one processing unit generates configuration data for at least onemanaged forwarding element, the first network controller modulecomprising sets of instructions for: receiving configuration input for alogical router, the configuration data comprising a first set of routesfor the logical router; offloading a route traversal process to aseparate second module of the network controller, wherein the routetraversal process returns a second set of routes; and generating a setof configuration data for configuring the at least one managedforwarding element to implement the logical router based on the secondset of routes.
 32. The non-transitory machine readable medium of claim31, wherein the route traversal process is a recursive route traversalprocess.
 33. The method of claim 31, wherein the first module is a tablemapping engine implemented in a table mapping language and the secondmodule is a route processing engine implemented in an object-orientedprogramming language.
 34. The non-transitory machine readable medium ofclaim 31, wherein each route in the first set of routes specifies one of(i) a next hop network address, (ii) an output port, and (iii) a droppacket action for packets with network addresses in a network addressrange for which the route is defined.
 35. The non-transitory machinereadable medium of claim 34, wherein, to perform the route traversalprocess, the second module (i) removes from the second set of routes allroutes for a particular network address range other than a highestpriority route for the particular network address range, when the firstset of routes comprises multiple routes for a particular network addressrange, (ii) removes from the second set of routes any route in the firstset of routes that specifies an output port that does not exist or thatis not in use, and (iii) identifies, for each route in the first set ofroutes that specifies a next hop network address, one of an output portand a drop packet action by traversing the first set of routes based onthe next hop network address.
 36. The non-transitory machine readablemedium of claim 31, wherein the set of configuration data is a first setof configuration data, the first network controller module furthercomprising a set of instructions for generating a second set ofconfiguration data based on configuration input received for a logicalswitch without using any data generated by the route processing engine.37. The non-transitory machine readable medium of claim 36, wherein thenetwork controller is a first network controller, wherein theconfiguration input for the logical switch is received through aninterface with a second network controller.
 38. The non-transitorymachine readable medium of claim 31, wherein the managed forwardingelements comprise L3 gateways implemented at gateway host machines inorder to connect a logical network, to which the logical router belongs,to an external network.
 39. The non-transitory machine readable mediumof claim 31, wherein the managed forwarding elements comprise first-hopmanaged forwarding elements that operate in virtualization software of aplurality of host machines at which virtual machines that communicatethrough a logical network are hosted, wherein the logical router is oneof a set of logical forwarding elements of the logical network.
 40. Thenon-transitory machine readable medium of claim 31, wherein theconfiguration input is received through a set of application programminginterfaces of the network controller.